<?php

/**
 * DebitMemo form.
 *
 * @package    erp-crm
 * @subpackage form
 * @author     Milwell H. Sia
 * @version    SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $
 */
class DebitMemoForm extends BaseDebitMemoForm
{
  public function configure()
  {
    if($this->isNew()){
      $this->validatorSchema['customer_iden'] = new sfValidatorString(array('required' => true));
      $this->validatorSchema['debit_iden'] = new sfValidatorString(array('required' => true));
      $this->setDefault('amount',0);
    }
    
    $this->validatorSchema['invoice_iden'] = new sfValidatorString(array('required' => false));
    $this->widgetSchema['customer_iden'] = new sfWidgetFormInputHidden();
    $this->widgetSchema['invoice_iden'] = new sfWidgetFormInputHidden();
    $this->validatorSchema['amount']->setOption('min',0.01);

    $this->widgetSchema['debit_type'] = 
      new sfWidgetFormSelect(
        array('choices'=>ListDocumentTypesPeer::getList('DEBIT'),)
      );
    
    $this->widgetSchema->setLabels(
      array(
        'debit_type'=>'Debit#',
        'remarks'=>'Remarks',
        'amount'=>'Amount',
      )
    );
    
   
  }
  
  public function getUrl(){
    if($this->isNew())
      return 'debitMemo/insert';
    else
      return '#';
  }

  public function setNumberReadOnly(){
    $this->widgetSchema['debit_number']->setAttribute('readonly',true);
  }
  
  public function setNumberTypeReadOnly(){
    $this->widgetSchema['debit_type']->setAttribute('onFocus','this.blur();');
    $this->widgetSchema['debit_number']->setAttribute('readonly',true);
  }

  
}
